<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD Xhtml 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/Dtd/xhtml1-transitional.dtd">
<!--
 *************************************************************************
 * The contents of this file are subject to the Openbravo  Public  License
 * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
 * Version 1.1  with a permitted attribution clause; you may not  use this
 * file except in compliance with the License. You  may  obtain  a copy of
 * the License at http://www.openbravo.com/legal/license.html 
 * Software distributed under the License  is  distributed  on  an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific  language  governing  rights  and  limitations
 * under the License. 
 * The Original Code is Openbravo ERP. 
 * The Initial Developer of the Original Code is Openbravo SLU 
 * All portions are Copyright (C) 2008-2012 Openbravo SLU
 * All Rights Reserved. 
 * Contributor(s):  ______________________________________.
 ************************************************************************
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Email options</title>
    <link rel="shortcut icon" href="../../../../../web/images/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" type="text/css" href="../../../../../web/skins/Default/Openbravo_ERP_250.css" id="paramCSS" />
    <script language="JavaScript" type="text/javascript" id="paramDirectory">
      var baseDirectory = "../../../../../web/";
      </script>      
      </script>
      <script language="JavaScript" src="../utility/DynamicJS.js" type="text/javascript"></script>
      <script language="JavaScript" type="text/javascript" id="paramLanguage">
        var defaultLang = "en_US";
      </script>
      <script language="JavaScript" src="../../../../../web/js/shortcuts.js" type="text/javascript"></script>
      <script language="JavaScript" src="../../../../../web/js/utils.js" type="text/javascript"></script>
      <script language="JavaScript" src="../../../../../web/js/messages.js" type="text/javascript"></script>
      <script language="JavaScript" src="../../../../../web/js/windowKeyboard.js" type="text/javascript"></script>
      <script language="JavaScript" src="../../../../../web/js/searchs.js" type="text/javascript"></script>
      <script language="JavaScript" src="../../../../../web/js/ajax.js" type="text/javascript"></script>
      <script language="JavaScript" src="../../../../../web/js/default/MessageBox.js" type="text/javascript"></script>
      <script language="JavaScript" src="../../../../../web/js/dojoConfig.js" type="text/javascript"></script>
      <script language="JavaScript" src="../../../../../web/js/dojo/dojo.js" type="text/javascript"></script>
      <script type="text/javascript">
        dojo.hostenv.writeIncludes(); //makes debugging in Venkman possible
      </script>
  	<SCRIPT language="JavaScript" type="text/javascript">
		
	function closeThisPage() {
		closePage();
		return true;
	}

	function submitThisPage(strCommand) {
		submitCommandForm(strCommand, false, null, null);
		return true;
	}
	
	function actionSendEmail()
	{
			submitThisPage('EMAIL');
	}

	function closePopUp()
	{
			closePage();
	}

	function addFile()
	{
			submitThisPage('ADD');
	}
  
	
	function resizeWindow()
	{
		popupResizeTo(750, 550);
	}

	function doDelete(myId)
	{
		document.getElementById("idToDelete").value=myId;
		submitThisPage('DEL');
		
	}

	var toEmailOrig;
	var ccEmailOrig;
	var bccEmailOrig;
	var replyToEmailOrig;

	function onLoadDo(){
    modifyInputFile('inpFile');
		if (document.getElementById("paramArchive").value == "Y"){
			document.getElementById("paramcheck").checked=true
		}
		var isClosed = document.getElementById("closed").value;
		if( isClosed == "yes")
		{
			closeThisPage();
		}

		toEmailOrig = document.getElementById('toEmailOrig').value;
		ccEmailOrig = document.getElementById('ccEmailOrig').value;
		bccEmailOrig = document.getElementById('bccEmailOrig').value;
		replyToEmailOrig = document.getElementById('replyToEmailOrig').value;
		manageFieldValueChange('toEmail');
		manageFieldValueChange('ccEmail');
		manageFieldValueChange('bccEmail');
		manageFieldValueChange('replyToEmail');

		if (document.getElementById('ccEmail').value !== '') {
			document.getElementById('cc').style.display = '';
			document.getElementById('cc_bottomMargin').style.display = '';
		}
		if (document.getElementById('bccEmail').value !== '') {
			document.getElementById('bcc').style.display = '';
			document.getElementById('bcc_bottomMargin').style.display = '';
		}

		this.windowTables = new Array(
		  new windowTableId('client')
		);
		setWindowTableParentElement();
		enableShortcuts('popup');
		setBrowserAutoComplete(false);
		
		var draftDocumentIds = document.getElementById("draftDocumentIds").value;
		if( draftDocumentIds != "" )
		{
			var documentIds = draftDocumentIds.split( "," );
			for( var index = 0; index < documentIds.length; index++ )
			{
				var documentId = documentIds[index];
			}
		} 
		setWindowElementFocus('firstElement');
        resizeWindow();
	}

	function onResizeDo(){
		//resizeArea(); // Removed to avoid double-scroll problems, since the html is not built using 2.50 standards
	}

	function showMoreFields() {
		document.getElementById('from').style.display = '';
		document.getElementById('from_bottomMargin').style.display = '';
		document.getElementById('cc').style.display = '';
		document.getElementById('cc_bottomMargin').style.display = '';
		document.getElementById('bcc').style.display = '';
		document.getElementById('bcc_bottomMargin').style.display = '';
		document.getElementById('showMoreFields').style.display = 'none';
		document.getElementById('showMoreFields_bottomMargin').style.display = 'none';
	}

	function manageFieldValueChange(field) {
		var fieldName = field.substring(0, field.length-5)+'Name';
		if (document.getElementById(field) && document.getElementById(fieldName)) {
			currentValue = document.getElementById(field).value;
			originalValue = eval(field + 'Orig');
			if (originalValue !== currentValue) {
				document.getElementById(fieldName).style.display = 'none';
			} else {
				document.getElementById(fieldName).style.display = '';
			}
		}
	}

	function storeDoc(){
		if (document.getElementById("paramArchive").value=='' || document.getElementById("paramArchive").value=='N') {
			document.getElementById("paramArchive").value='Y';
		} else {
			document.getElementById("paramArchive").value='N';
			}
	}
	
  function modifyInputFile(id) {
    var object = document.getElementById(id);
    if (getBrowserInfo('name').toUpperCase().indexOf('CHROME') !== -1) {
      object.style.padding = '0px';
      object.style.margin = '0px';
      object.style.height = '23px';
      object.style.background = 'none !important';
      object.style.border = 'none';
    }
    object.style.display = '';
  }

  function templateChanged() {
    var callback = function (paramXMLParticular, XMLHttpRequestObj) {
        var o, fileName;
        if (getReadyStateHandler(XMLHttpRequestObj)) {
          try {
            if (XMLHttpRequestObj.responseText) {
              strText = XMLHttpRequestObj.responseText;
            }
          } catch (e) {}
          o = eval('('+strText+')');
          if (!o.error) {
            document.getElementById('emailSubject').value = o.subject;
            document.getElementById('emailBody').innerHTML = o.body;

            if (o.filename){
              fileName = document.getElementById('fileDocName');
              fileName.removeChild(fileName.childNodes[0]);
              fileName.appendChild(document.createTextNode(o.filename));
            }
          }
        }
        return true;
      },
    frm = document.frmMain;

    return submitXmlHttpRequest(callback, frm, 'UPDATE_TEMPLATE', 'PrintOptions.html', false);
  }
</script>

</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="onLoadDo();" onresize="onResizeDo();">
<form id="form" method="POST" action="PrintOptions.html" name="frmMain" enctype="multipart/form-data">
	
	<input type="hidden" name="Command"></input>
	<input type="hidden" name="IsPopUpCall" value="1"></input>
	<input type="hidden" name="inpLastFieldChanged"></input>
	<input type="hidden" name="inpKey" value="" id="paramKey"></input>
	<input type="hidden" name="inpwindowId" value="" id="window"></input>
	<input type="hidden" name="inpTabId" value="" id="tab"></input>
	<input type="hidden" name="inpDocumentId" id="strDocumentId" value=""></input>
	<input type="hidden" name="draftDocumentIds" id="draftDocumentIds" value=""></input>
	<input type="hidden" name="closed" id="closed" value=""></input>
	<input type="hidden" name="idToDelete" id="idToDelete" value=""></input>

	<input type="hidden" name="toEmailOrig" id="toEmailOrig" value=""></input>
	<input type="hidden" name="ccEmailOrig" id="ccEmailOrig" value=""></input>
	<input type="hidden" name="bccEmailOrig" id="bccEmailOrig" value=""></input>
	<input type="hidden" name="replyToEmailOrig" id="replyToEmailOrig" value=""></input>
	
	

<div class="Popup_ContentPane_CircleLogo">
<div class="Popup_WindowLogo"><img
	class="Popup_WindowLogo_Icon Popup_WindowLogo_Icon_process"
	src="../../../../../web/images/blank.gif" border=0></img></div>
</div>

<table cellspacing="0" cellpadding="0" width="100%">
    <tr>
      <td>
        <table cellspacing="0" cellpadding="0" class="Popup_ContentPane_NavBar">
          <tr class="Popup_NavBar_bg"><td></td>
            <td class="Popup_NavBar_separator_cell"></td>
            <td class="Popup_NavBar_bg_logo_left"></td>
            <td class="Popup_NavBar_bg_logo" width="1" onclick="openNewBrowser('http://www.openbravo.com', 'Openbravo');return false;"><IMG src="../../../../../web/images/blank.gif" alt="Openbravo" title="Openbravo" border="0" id="openbravoLogo" class="Popup_NavBar_logo" /></td>
            <td class="Popup_NavBar_bg_logo_right"></td>
            <td class="Popup_NavBar_Popup_title_cell"><span>Email Document</span></td>
            <td class="Popup_NavBar_separator_cell"></td>
          </tr>
        </table>
      </td>
    </tr>

	<tr>
		<td>
		<table cellspacing="0" cellpadding="0"
			class="Popup_ContentPane_SeparatorBar">
			<tr>
				<td class="Popup_SeparatorBar_bg"></td>
			</tr>
		</table>
		</td>
	</tr>

	<tr>
		<td>

		<div style="margin: 10px;" id="client">

		<table cellspacing="0" cellpadding="0 style="height: 150px; overflow: auto;" class="form_table">

					<tr id="from" style="display: none;">
						<td style="width: 1%; text-align: right;">
							<span style="white-space: nowrap; padding-right: 10px;" class="LabelText">From</span>
						</td>
						<td id="fromEmailArea"colspan="2">
							<input type="hidden" name="fromEmailId" id="fromEmailId" value=""></input>
							<input style="width: 55%;" type="text" dojoType="openbravo:ValidationTextBox"
									class="dojoValidateValid readonly TextBox_btn_TwoCells_width"
									maxlength="200" name="fromEmail" id="fromEmail" value=""
									readonly="true"><span class="LabelText" name="fromName" id="fromName" value="" style="padding-left: 10px"></span>
									
						</td>
					</tr>
					<tr id="from_bottomMargin" style="display: none; height: 8px;">
					</tr>

					<tr id="to">
						<td style="width: 1%; text-align: right;">
							<span style="white-space: nowrap; padding-right: 10px;" class="LabelText">To</span>
						</td>
						<td id="toEmailArea"colspan="2">
							<input style="width: 55%;" type="text" dojoType="openbravo:ValidationTextBox"
									class="dojoValidateValid required TextBox_btn_TwoCells_width"
									maxlength="200" name="toEmail" id="toEmail" value=""
									onkeyup="manageFieldValueChange(this.id);" onchange="manageFieldValueChange(this.id);"
									required="true"><span class="LabelText" name="toName" id="toName" value="" style="padding-left: 10px"></span>
									
						</td>
					</tr>
					<tr id="to_bottomMargin"style="height: 8px">
					</tr>

					<tr id="multipleCustomer">
						<td>
						</td>
						<td class="LabelText"><span id="multCustomer">This email will be sent to </span>&nbsp;<span id="multCusCount" name="multCusCount"></span>&nbsp;<span id="multCustomer"> customers</span><span id="multSalesRep"><span>&nbsp;</span> by <span>&nbsp;</span></span><span id="multSalesRepCount" name="multSalesRepCount" ></span><span id="multSalesRep"><span>&nbsp;</span> sales reps</span>.</td>
					</tr>
					<tr id="multipleCustomer_bottomMargin"style="height: 8px">
					</tr>

					<tr id="cc" style="display: none;">
						<td style="width: 1%; text-align: right;">
							<span style="white-space: nowrap; padding-right: 10px;" class="LabelText">CC</span>
						</td>
						<td id="ccEmailArea"colspan="2">
							<input style="width: 55%;" type="text" dojoType="openbravo:ValidationTextBox"
									class="dojoValidateValid TextBox_btn_TwoCells_width"
									maxlength="200" name="ccEmail" id="ccEmail" value=""
									onkeyup="manageFieldValueChange(this.id);" onchange="manageFieldValueChange(this.id);"
									><span class="LabelText" name="ccName" id="ccName" value="" style="padding-left: 10px"></span>
									
						</td>
					</tr>
					<tr id="cc_bottomMargin" style="display: none; height: 8px;">
					</tr>

					<tr id="bcc" style="display: none;">
						<td style="width: 1%; text-align: right;">
							<span style="white-space: nowrap; padding-right: 10px;" class="LabelText">BCC</span>
						</td>
						<td id="ccEmailArea"colspan="2">
							<input style="width: 55%;" type="text" dojoType="openbravo:ValidationTextBox"
									class="dojoValidateValid TextBox_btn_TwoCells_width"
									maxlength="200" name="bccEmail" id="bccEmail" value=""
									onkeyup="manageFieldValueChange(this.id);" onchange="manageFieldValueChange(this.id);"
									><span class="LabelText" name="bccName" id="bccName" value="" style="padding-left: 10px"></span>
									
						</td>
					</tr>
					<tr id="bcc_bottomMargin" style="display: none; height: 8px;">
					</tr>

					<tr id="replyTo">
						<td style="width: 1%; text-align: right;">
							<span style="white-space: nowrap; padding-right: 10px;" class="LabelText">Reply-to</span>
						</td>
						<td id="replyToEmailArea" colspan="2">
							<input style="width: 55%;" type="text" dojoType="openbravo:ValidationTextBox"
									class="dojoValidateValid required TextBox_btn_TwoCells_width"
									maxlength="200" name="replyToEmail" id="replyToEmail" value=""
									onkeyup="manageFieldValueChange(this.id);" onchange="manageFieldValueChange(this.id);"
									required="true"><span class="LabelText" name="replyToName" id="replyToName" value="" style="padding-left: 10px"></span>
									
						</td>
					</tr>
					<tr id="replyTo_bottomMargin"style="height: 8px">
					</tr>

					<tr id="showMoreFields">
						<td style="width: 1%; text-align: right;">
							<span style="white-space: nowrap; padding-right: 10px;" class="LabelText"></span>
						</td>
						<td id="showMoreFieldsArea" class="DataGrid_Body_Cell" style="border: 0; background-color: transparent;" colspan="2">
							<a href="#" class="LabelLink_noicon" onclick="showMoreFields(); return false;">[ Show More Fields ]</a>
						</td>
					</tr>
					<tr id="showMoreFields_bottomMargin" style="height: 8px">
					</tr>

					<tr id="emailField03">
						<td style="width: 1%; text-align: right;">
							<span style="white-space: nowrap; padding-right: 10px;" class="LabelText">Subject</span>
						</td>
						<td colspan="2">
							<input style="width: 55%;" type="text" dojoType="openbravo:ValidationTextBox"
										class="dojoValidateValid required TextBox_btn_TwoCells_width"
										maxlength="200" name="emailSubject" id="emailSubject" value=""
										required="true">
						</td>
						
					</tr>
					<tr style="height: 8px">
                    </tr>

					<tr id="emailField03" nowrap="nowrap">
						<td style="width: 1%; text-align: right; vertical-align: top" >
							<span style="white-space: nowrap; padding-right: 10px;" class="LabelText">Message Body</span>
						</td>
						<td nowrap="nowrap" style="width: 55%;">
							<textarea id="emailBody" style="height: 100px; width: 99.1%;" class="dojoValidateValid" maxlength="2000" name="emailBody" onkeyup="" onchange=""></textarea>
						</td>
						<td>
							<ul class="LabelText"  style="list-style: none; padding-left: 10px;" >
								<li>References will be replaced by values:</li>
								<li>@cus_ref@: The document reference of the customer</li>
								<li>@our_ref@: The reference of the document</li>
								<li>@cus_nam@: The name of the customer</li>
								<li>@sal_nam@: The name of the sales rep.</li>
							</u>
						</td>
					</tr>
					<tr style="height: 8px">
                    </tr>
					<tr id="discardSelect">
 						<td class="TitleCell"><span class="LabelText">Template to use</span></td>
						<td colspan="2">
	    					<select style="width: 55%;" name="templates" id="templates" class="ComboKey Combo_TwoCells_width" required="true" onchange="templateChanged();return true;">
	                    	<div id="reportEmail"></div>
	        			</select>
						</td>
				</tr>	
				<tr style="height: 8px">
                    </tr>	
					<tr id="discardTable">
						<td style="width: 1%; text-align: right;">
							<span style="white-space: nowrap; padding-right: 10px;" class="LabelText">Attached Documents</span>
						</td>	
   						 <td colspan="2">
    						<table cellspacing="0" cellpadding="0" width="55%"  style="table-layout: auto;">
    						<tbody>
    						<tr class="DataGrid_Body_Row"> 
    							<th class="DataGrid_Header_Cell"><span>File name</span></th>
      							<th width="20%" colspan="1" class="DataGrid_Header_Cell" id="fieldPartnerName"><span>Archive</span><th>
        					</tr>
        					<div id="sectionDetail2">
        					<tr id="funcEvenOddRowxx" class="DataGrid_Body_Row DataGrid_Body_Row_xx">
      							<td class="DataGrid_Body_Cell" id="fileDocName" value="tt">xx</td>
								<td width="20" class="DataGrid_Body_Cell" style="text-align: center;"><span class="Checkbox_container_NOT_Focused"><input type="checkbox" id="paramcheck" name="paramcheck" onclick="javascript:storeDoc();"/></span></td>
         					</tr>
    						<div id="sectionDetail">
      						<tr id="view" class="DataGrid_Body_Row DataGrid_Body_Row_xx">
      							<td class="DataGrid_Body_Cell" id="paramName">xx<span>&nbsp;&nbsp;</span><a type="hidden" id="linkLocator" href="#" class="LabelLink_noicon" onclick="javascript:doDelete('yy');return true;">[ Remove ]</a></td>
								<td width="20" class="DataGrid_Body_Cell"><span class="Checkbox_container_NOT_Focused"><input type="hidden" id="paramId" name="field-xx"/></span></td>
         					</tr>
    					</div>
    					</tbody>
    					</table>
					</td>
				</tr>
				
				<tr id="emailField03">
					<td>
					</td>
					<td colspan="2" class="TextBox_ContentCell">
                    	<input type="text" onblur="isInputFile=false;" onfocus="isInputFile=true;" style="border: 0pt none ; margin: 0pt; padding: 0pt; font-size: 0pt; width: 0px; height: 0px;"/>
                    	<input type="file" size="32px" name="inpFile" id="inpFile" class="dojoValidateValid TextBox_TwoCells_width" style="display: none;"/>
                    	<input type="text" onblur="isInputFile=false;" onfocus="isInputFile=true;" style="border: 0pt none ; margin: 0pt; padding: 0pt; font-size: 0pt; width: 0px; height: 0px;"/>
   	 				</td>
				</tr>
				<tr style="height: 8px">
                    </tr>	
				<tr>
					<td>
					</td>
					<td colspan="2" id="CopyFrom_inp_td" class=""><div id="editDiscard"><div id="CopyFrom_inp">
  <input type="hidden" id="CopyFrom" onchange="logChanges(this.inputNode);return true;" value="N" name="inpcopyfrom"/>
  <button type="button" 
    id="CopyFrom_linkBTN" 
    class="ButtonLink" 
    onclick="addFile();return false;" 
    onfocus="buttonEvent('onfocus', this); window.status='Add Attachment'; return true;" 
    onblur="buttonEvent('onblur', this);" 
    onkeyup="buttonEvent('onkeyup', this);" 
    onkeydown="buttonEvent('onkeydown', this);" 
    onkeypress="buttonEvent('onkeypress', this);" 
    onmouseup="buttonEvent('onmouseup', this);" 
    onmousedown="buttonEvent('onmousedown', this);" 
    onmouseover="buttonEvent('onmouseover', this); window.status='Add Attachment'; return true;" 
    onmouseout="buttonEvent('onmouseout', this);">
    <table class="Button">
      <tr>
        <td class="Button_left"><img border="0" src="../web/images/blank.gif" title="Add Attachment" alt="Add Attachment" class="Button_Icon Button_Icon_process"></td>
        <td id="CopyFrom_BTNname" class="Button_text">Add Attachment</td>
        <td class="Button_right"></td>        
      </tr>
    </table>
   </button>
</div></div></div></td></td></tr></div>
</div></td>
</tr>

					<tr id="emailField03">						
						<td style="width: 1%; text-align: right; white-space: nowrap; padding-right: 10px;"> <input type="hidden" id="paramArchive" name="inpArchive" value="""/></td>
						<td  colspan="2" style="width: 99%"></td>			
					</tr>	
					</table>
				
					<table cellspacing="0" cellpadding="0" style="margin: 0px; padding: 0px;" class="Popup_Client_TablePopup">	
					<tr>
						<td class="Button_RightAlign_ContentCell" style="padding-top: 30px">
							<div>
                <button type="button" 
                  class="ButtonLink" 
                  onclick="actionSendEmail();return false;" 
                  onfocus="buttonEvent('onfocus', this); window.status='Send'; return true;" 
                  onblur="buttonEvent('onblur', this);" 
                  onkeyup="buttonEvent('onkeyup', this);" 
                  onkeydown="buttonEvent('onkeydown', this);" 
                  onkeypress="buttonEvent('onkeypress', this);" 
                  onmouseup="buttonEvent('onmouseup', this);" 
                  onmousedown="buttonEvent('onmousedown', this);" 
                  onmouseover="buttonEvent('onmouseover', this); window.status='Send'; return true;" 
                  onmouseout="buttonEvent('onmouseout', this);">
                  <table class="Button">
                    <tr>
                      <td class="Button_left"><img class="Button_Icon Button_Icon_ok" alt="Send" title="Send" src="../../../../../web/images/blank.gif" border="0" /></td>
                      <td class="Button_text Button_width">Send</td>
                      <td class="Button_right"></td>
                    </tr>
                  </table>
                </button>
							</div>
						</td>
						<td class="Button_LeftAlign_ContentCell" style="padding-top: 30px">
							<div>
                <button type="button" 
                  id="buttonCancel" 
                  class="ButtonLink" 
                  onclick="closePopUp();return false;" 
                  onfocus="buttonEvent('onfocus', this); window.status='Cancel'; return true;" 
                  onblur="buttonEvent('onblur', this);" 
                  onkeyup="buttonEvent('onkeyup', this);" 
                  onkeydown="buttonEvent('onkeydown', this);" 
                  onkeypress="buttonEvent('onkeypress', this);" 
                  onmouseup="buttonEvent('onmouseup', this);" 
                  onmousedown="buttonEvent('onmousedown', this);" 
                  onmouseover="buttonEvent('onmouseover', this); window.status='Cancel'; return true;" 
                  onmouseout="buttonEvent('onmouseout', this);">
                  <table class="Button">
                    <tr>
                      <td class="Button_left"><img class="Button_Icon Button_Icon_cancel" alt="Cancel" title="Cancel" src="../../../../../web/images/blank.gif" border="0" /></td>
                      <td class="Button_text Button_width">Cancel</td>
                      <td class="Button_right"></td>
                    </tr>
                  </table>
                </button>
							</div>
						</td>
					</tr>
					</table>
				
				</div>
			</td>
		</tr>


</table>
</form>
</body>
</html>
